﻿package mortal.game.view.copy.sixBoss.renderer
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.gengine.utils.*;
    import com.mui.controls.*;
    import com.mui.utils.*;
    import extend.language.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.common.global.*;
    import mortal.game.*;
    import mortal.game.manager.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.scene3D.ai.*;
    import mortal.game.scene3D.layer3D.utils.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.sixBoss.view.*;

    public class SixBossKillInfoCellRenderer extends GCellRenderer
    {
        private var _bossName:GTextFiled;
        private var _findRoad:GTextFiled;
        private var _detail:GTextFiled;
        private var _blood:GTextFiled;
        private var _bloodBar:BaseProgressBar;
        private var _bossIsDied:GTextFiled;
        private var _bossInfo:SMonsterSiegeBossInfo;

        public function SixBossKillInfoCellRenderer()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bossName = UIFactory.gTextField("", 0, 0, 77, 20, this);
            this._findRoad = UIFactory.gTextField("", 61, 0, 29, 20, this);
            this._findRoad.htmlText = HTMLUtil.addLink(Language.getString(40903), GlobalStyle.colorHuang2);
            this._findRoad.configEventListener(MouseEvent.CLICK, this.onLinkClickHandler);
            this._findRoad.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._findRoad.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this._detail = UIFactory.gTextField("", 89, 0, 29, 20, this);
            this._detail.htmlText = HTMLUtil.addLink(Language.getString(40904), GlobalStyle.colorHuang2);
            this._detail.configEventListener(MouseEvent.CLICK, this.onLinkClickHandler);
            this._detail.configEventListener(MouseEvent.MOUSE_OVER, this.onOverHandler);
            this._detail.configEventListener(MouseEvent.MOUSE_OUT, this.onOutHandler);
            this._blood = UIFactory.gTextField(Language.getString(40905), 0, 24, 26, 20, this, GlobalStyle.textFormatHuang2);
            this._bloodBar = UICompomentPool.getUICompoment(BaseProgressBar);
            this._bloodBar.setBg(ImagesConst.PetLifeBg, true, 85, 13);
            this._bloodBar.setProgress(ImagesConst.GuildWarSelfProgress, true, (2 - 1), (1 + 1), 83, 10);
            this._bloodBar.setLabel(BaseProgressBar.ProgressBarTextPercent, 27, -4, 35, 20, GlobalStyle.textFormatBai);
            this._bloodBar.setValue(100, 100);
            this._bloodBar.x = 26;
            this._bloodBar.y = 24 + 4;
            this.addChild(this._bloodBar);
            this._bossIsDied = UIFactory.gTextField(Language.getString(40906), 23, 21, 102, 25, this, GlobalStyle.textFormatHong.setSize(15));
            this._bossIsDied.visible = false;
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_2:TBoss = null;
            super.data = param1;
            this._bossInfo = param1 as SMonsterSiegeBossInfo;
            if (this._bossInfo)
            {
                _loc_2 = BossConfig.instance.getInfoByCode(this._bossInfo.bossCode);
                if (_loc_2)
                {
                    this._bossName.text = _loc_2.name;
                }
                if (this._bossInfo.lifePer == 0)
                {
                    this._bloodBar.visible = false;
                    this._blood.visible = false;
                    this._bossIsDied.visible = true;
                }
                else
                {
                    this._bloodBar.visible = true;
                    this._blood.visible = true;
                    this._bossIsDied.visible = false;
                    this._bloodBar.setValue(this._bossInfo.lifePer, 100);
                }
            }
            return;
        }// end function

        private function onLinkClickHandler(event:MouseEvent) : void
        {
            var _loc_2:IEntity = null;
            var _loc_3:SPoint = null;
            var _loc_4:Point = null;
            if (event.target == this._findRoad)
            {
                if (this._bossInfo == null)
                {
                    return;
                }
                _loc_2 = ThingUtil.entityUtil.getEntity(this._bossInfo.bossId);
                if (_loc_2 == null)
                {
                    MsgManager.showRollTipsMsg(Language.getString(40906));
                    return;
                }
                _loc_3 = _loc_2.entityInfo.entityInfo.points[0];
                if (_loc_3)
                {
                    _loc_4 = new Point(_loc_3.x, _loc_3.y);
                    AIManager.onAIControl(AIType.GoToOtherMap, Game.mapInfo.mapId, Game.mapInfo.mapId, _loc_4);
                }
            }
            if (event.target == this._detail)
            {
                if (SixBossInfoWin.instance.isHide)
                {
                    SixBossInfoWin.instance.show();
                }
                SixBossInfoWin.instance.data = this._bossInfo;
            }
            return;
        }// end function

        private function onOverHandler(event:MouseEvent) : void
        {
            CursorManager.showCursor(CursorManager.BUTTON);
            return;
        }// end function

        private function onOutHandler(event:MouseEvent) : void
        {
            CursorManager.hideFromButton();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._bossName.dispose();
            this._bossName = null;
            this._findRoad.dispose();
            this._findRoad = null;
            this._detail.dispose();
            this._detail = null;
            this._blood.dispose();
            this._blood = null;
            this._bloodBar.dispose();
            this._bloodBar = null;
            this._bossIsDied.dispose();
            this._bossIsDied = null;
            this._bossInfo = null;
            return;
        }// end function

    }
}
